package com.pearl.web.demo.validation;

import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Past;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import java.util.Date;

/**
 *
 * @author TangDan
 * @version 1.0
 * @since 2023/4/14
 */
@Data
public class SaveUserParam {
    @NotEmpty(message = "用户名不能为空",groups = {Select.class,Insert.class})
    @Pattern(message = "用户名只能是数字字母",regexp = "^[A-Za-z0-9-]*",groups = {Select.class,Insert.class})
    String userName;

    @NotEmpty(message = "密码不能为空",groups = {Insert.class})
    @Length(min = 8, max = 20, message = "密码长度必须在8-20之间",groups = {Insert.class})
    String password;

    @Past(message = "生日不能小于当前时间")
    Date birthday;

    @Range(min = 1,max = 120,message = "年龄必须在1-120之间")
    int age;
}
